package strukturaSviatky;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Sviatok {

    private String popisSviatku;
    private Calendar datumCalendar;

    public Sviatok(String datum, String popis) throws ParseException {
        final String DATE_FORMAT = "dd.MM.yyyy";
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
        datumCalendar = new GregorianCalendar();
        datumCalendar.setTime(sdf.parse(datum));
        popisSviatku = popis;
    }

    public Sviatok(Calendar datum, String popis) throws ParseException {
        datumCalendar = datum;
        popisSviatku = popis;
    }

    public String getPopis() {
        return popisSviatku;
    }

    public String getDatum() {
        final String DATE_FORMAT = "dd.MM.yyyy";
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
        return sdf.format(datumCalendar.getTime());
    }

    public String getDatumSQL() {
        final String DATE_FORMAT = "yyyy-MM-dd";
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
        return sdf.format(datumCalendar.getTime());
    }

    public int getDay() {
        final String DATE_FORMAT = "dd";
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
        return Integer.parseInt(sdf.format(datumCalendar.getTime()));
    }
    
    public int getMonth() {
        final String DATE_FORMAT = "MM";
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
        return Integer.parseInt(sdf.format(datumCalendar.getTime()));
    }
    
    public int getYear() {
        final String DATE_FORMAT = "yyyy";
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
        return Integer.parseInt(sdf.format(datumCalendar.getTime()));
    }
}
